package org.batatasframework.bytecode;

import org.batatasframework.bytecode.spi.AsmLoadable;
import org.springframework.asm.MethodVisitor;

/**
 * 创建一个新的对象，并且这个新的对象可以直接赋值给某一个变量
 * @author jackson
 *
 */
public class InstanceObject implements AsmLoadable{
	
	private final ClassAsminfo clazz;
	
	public InstanceObject(ClassAsminfo clazz){
		this.clazz = clazz;
	}
	
	@Override
	public void load(MethodVisitor visitor, ClassAsminfo targetType) {
		clazz.instance(visitor);
		targetType.cast(visitor, clazz);
	}

	@Override
	public void load(MethodVisitor visitor) {
		clazz.instance(visitor);
	}
}
